package com.example.administrator.threaduidemo;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.MessageQueue;
import android.util.Log;

import java.lang.reflect.Modifier;

/**
 * Created by mhysa on 2017/3/9.
 * 自定义handler
 */

public class HandlerDefine {

    private static final boolean FIND_POTENTIAL_LEAKS = false;
    private static final String TAG = "Handler";
    public interface Callback {
        public boolean handleMessage(Message msg);
    }
    public void handmessage1(){

    }

    public HandlerDefine(){
        this(null,false);
    }
    public HandlerDefine(Callback callback, boolean async) {
        if (FIND_POTENTIAL_LEAKS) {
            final Class<? extends HandlerDefine> klass = getClass();
            if ((klass.isAnonymousClass() || klass.isMemberClass() || klass.isLocalClass()) &&
                    (klass.getModifiers() & Modifier.STATIC) == 0) {
                Log.w(TAG, "The following Handler class should be static or leaks might occur: " +
                        klass.getCanonicalName());
            }
        }

        Log.i("mhysa-->","走没走");
        Looper mLooper = Looper.myLooper();
        if (mLooper == null) {
            throw new RuntimeException(
                    "Can't create handler inside thread that has not called Looper.prepare()");
        }
       MessageQueue mQueue = null;
       Callback mCallback =  callback;
      //  mAsynchronous = async;
    }
}
